<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>角色管理</title>
    <%@include file="/WEB-INF/jsp/common/meta2.jsp" %>
</head>
<body class="content-body">
<div class="container-fluid">

    <table class="table table-responsive table-bordered">
        <tr>
            <th colspan="20" class="bg-info text-center">内容列表</th>
        </tr>
        <tr>
            <td colspan="20">

                <form id="listForm" action="${ctx}/common/role/list" method="get" class="form-inline" role="form">
                    <input type="hidden" name="pageNo" id="pageNo" value="${pageData.pagination.pageNo}"/>
                    <input type="hidden" name="pageSize" id="pageSize" value="10"/>
                    <input type="hidden" name="ascDesc" id="ascDesc" value="${pageData.ascDesc}"/>
                    <input type="hidden" name="orderName" id="orderName" value="${pageData.orderName}"/>

                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon">角色名称|编码：</div>
                            <input type="text" name="LIKE_S&name_OR_code" placeholder="角色名称|编码"
                                   class="input-sm form-control"
                                   value="${pageData.webMap['LIKE_S&name_OR_code'][0]}">
                        </div>
                    </div>
                    <input type="button" onclick="search()" value="查询" class="btn btn-info btn-sm"/>

                    <a href="${ctx}/common/role/new" class="btn btn-info pull-right btn-sm">添加角色</a>
                </form>
            </td>
        </tr>
        <tr>
            <th>#</th>
            <th onclick="sort('name')">资源名称</th>
            <th onclick="sort('code')">编码</th>
            <th onclick="sort('scope')" class="text-center">权限范围</th>
            <th onclick="sort('enable')">禁用</th>
            <th class="text-center">操作</th>
        </tr>
        <c:forEach items="${pageData.result}" var="entity" varStatus="i">
            <tr>
                <td class="center">
                        ${i.index + 1}
                </td>
                <td class="center">
                        ${entity.name}
                </td>
                <td class="center">
                        ${entity.code}
                </td>
                <td class="bg_blue">
                    <ul>
                        <c:forEach items="${entity.scopeData}" var="data">
                            <li>
                                <span class="glyphicon ${data.value.group.icon}"></span>
                                <span style="color: #000;">${data.value.group.name}：</span>
                            <span style="font-size: 12px;">|
                                <c:forEach items="${data.value.items}" var="resource">
                                    ${resource.name} |
                                </c:forEach>
                            </span>
                            </li>
                        </c:forEach>
                    </ul>
                </td>
                <td class="center">
                        ${entity.enable ? '是':'否'}
                </td>

                <td class="text-center">
                    <c:if test="${entity.id > 2}">
                        <a href="${ctx}/common/role/edit/${entity.id}">编辑</a>|
                        <a href="javascript:doDelete('${ctx}/common/role/delete/${entity.id}');">删除</a>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
        <c:if test="${fn:length(pageData.result) < 1}">
            <tr>
                <td colspan="20">无数据...</td>
            </tr>
        </c:if>
        </tbody>
    </table>


    <%@include file="/WEB-INF/jsp/common/pager.jsp" %>
</body>
</html>
<script>

    function doDelete(url) {
        if (confirm("确定执行该操作？")) {
            location.href = url;
        }
    }

</script>
